var Mock = require('mockjs')
const data = [];
for (let i = 0; i < 20; i++) {
    data.push(Mock.mock({
        name: Mock.mock('@cname()'),
        // 时间
        date: Mock.mock('@date'),
        // 
        address: Mock.Random.ip(),
        // 
        "number|1-100": 100,
        
       
        describe: Mock.mock('@csentence(5)'),
        'node|0-2': 1,
        legend: Mock.mock({
            "data|2": [
                "Mock.js"
            ]
        }),

        indicator: Mock.mock(
            {
                "name":
                    Mock.Random.province(),
                max: Mock.mock('@integer(3000, 8000)')
            }
        ),
      
        series: Mock.mock({
            name: Mock.mock('@cname()'),
            "data": [
                Mock.mock(Math.floor(Math.random() * 1000)),
                Mock.mock(Math.floor(Math.random() * 705)),
                Mock.mock(Math.floor(Math.random() * 504)),
                Mock.mock(Math.floor(Math.random() * 503)),
                Mock.mock(Math.floor(Math.random() * 200)),
                Mock.mock(Math.floor(Math.random() * 1230)),
                Mock.mock(Math.floor(Math.random() * 200)),
                Mock.mock(Math.floor(Math.random() * 1300)),
                Mock.mock(Math.floor(Math.random() * 750)),
            ],
        }),
        dataset: Mock.mock({
            "source": [
                [1212, 23, 545, 76767, 5656, 778], ['sds', 34, 8, 76], ['sereds', 'asa44rrsa'], ['sds', 'asasa']
            ],

        }),
        dataList: Mock.mock({
            "value": [
                Mock.mock('@integer(3000, 5000)'),
                Mock.mock('@integer(3000, 6000)'),
                Mock.mock('@integer(3000, 8000)'),
                Mock.mock('@integer(3000, 5000)'),
                Mock.mock('@integer(3000, 4000)'),
                Mock.mock('@integer(3000, 5000)'),
                Mock.mock('@integer(3000, 11000)'),
            ],
        }),
 
        //   -------------------------------data----------------------------------
        data: Mock.mock({
            "value":
                Mock.mock(Math.floor(Math.random() * 100))
            ,
            "name": Mock.mock('@cname()')
        })
    }))

}

const vehicle = Mock.mock(/\/Service\/ServiceList/, 'get', data)
console.log('%c前端 mock 环境启动成功', 'color: #38f;font-weight: bold')
export default {
    vehicle,
}


// qingqiu
import axios from 'axios';


let arr = []
axios({
    url: '/\/Service\/ServiceList/',
    method: 'get',
}).then((res) => {
    let { data } = res
    arr.push(...data)
    console.log(data,'------------mock数据------------');
})

const Random = Mock.Random
let dataList = [] // 用于接受生成数据的数组
for (let i = 0; i < 40; i++) { // 可自定义生成的个数
    let template = Mock.mock({
        "describe":
        Mock.mock('@csentence(5)')
        ,
        "address": Mock.Random.ip(),
        "name": Mock.mock('@cname()'),
        date: Mock.mock('@date'),
        // 
        address: Mock.Random.ip(),
        // 
    })
    dataList.push(template)
}

// 模拟分页及搜索
Mock.mock('http://localhost:8080/questions/randomsss/', 'post', (params) => {
    var listQuery = JSON.parse(params.body)
    // var keyword = listQuery.keyword
    // console.log(listQuery)
    var pageIndex = (listQuery.page - 1) * listQuery.pagesize
    var [index, size, counts] = [pageIndex, listQuery.pagesize, dataList.length]
    var items = dataList.slice(index, index + size)
   
    return {
        'code': '200',
        'message': 'success',
        'data': {
            'listQuery': listQuery,
            'tableData': items,
            'counts': counts
        }
    }
})
export { arr }
